﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace Groovy_IM.ViewModels.Accounts
{
    public class AccountViewModel : INotifyPropertyChanged
    {
        public AccountViewModel()
        {
            this.Items = new ObservableCollection<AccountItemViewModel>();
        }

        public ObservableCollection<AccountItemViewModel> Items { get; private set; }

        public void RemoveItem(int Index)
        {
            this.Items.Remove(this.Items[Index]);

            recountTag(Index);
        }

        public void recountTag(int remIndex)
        {
            for (int i = 0; i < this.Items.Count; i++)
            {
                this.Items[i].Tag = Convert.ToString((i));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
